﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sunboxsoft.WinForm;
using DevExpress.XtraEditors;
using System.Text.RegularExpressions;

namespace Sunboxsoft.ASMS.Client.UI.Common.Validations
{
    /// <summary>
    /// 验证电话格式
    /// </summary>
    public class TextEditTelephoneValidation : TextEditRegexValidation
    {
        /// <summary>
        /// 验证电话格式
        /// </summary>
        /// <param name="textEdit"></param>
        public TextEditTelephoneValidation(TextEdit textEdit, bool isRequired)
            : base(textEdit, @"\d{11}$", "电话号码", isRequired)
        {
        }
        public override bool ValueChanging(string newValue)
        {
            Regex regex = new Regex(@"^[0-9]*$");
            if (regex.IsMatch(newValue) && newValue.Length <= 11)
            {
                return true;
            }
            return false;
        }
    }
}
